﻿<%@ Page Language="C#" MasterPageFile="~/Hoso/MasterPage_Hoso.master" AutoEventWireup="true" CodeFile="QuanlyTaikhoanofbacsi.aspx.cs" Inherits="Hoso_QuanlyTaikhoanofbacsi" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<div style="padding-left:10px;padding-top:10px; width: 264px;">
    <asp:HyperLink ID="HyperLink1" runat="server" ForeColor="#003300" 
        NavigateUrl="~/Hoso/QuanlyBaivietofbacsi.aspx">QUẢN LÝ BÀI VIẾT </asp:HyperLink>
        <br />
        <br />
        <asp:HyperLink ID="HyperLink3" runat="server" ForeColor="#003300" 
        NavigateUrl="~/Hoso/QuanlyTaikhoanofbacsi.aspx">QUẢN LÝ TÀI KHOẢN</asp:HyperLink>
        <br />
        <br />
        <asp:HyperLink ID="HyperLink5" runat="server" ForeColor="#003300" 
        NavigateUrl="~/Hoso/HosoBacsidoipass.aspx">ĐỔI PASS VÀ EMAIL</asp:HyperLink>
        <br />
        <br />
        </div>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder3" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

            <script type="text/javascript">
            function RowDblClick(sender, eventArgs)
            {
              sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }
            </script>

        </telerik:RadCodeBlock>
        
         <!-- load ajax-->
         <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
        </telerik:RadAjaxManager>
        <!-- end-->
   
   <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" 
            BackColor="#99FF66" Skin="WebBlue" />
    <asp:Label ID="Label1" runat="server" Text=""></asp:Label> 
    <asp:Label ID="Label2" runat="server" Text=""></asp:Label>
    
        <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" 
        AllowMultiRowEdit ="True" AllowMultiRowSelection="True"
        DataSourceID="SqlDataSource1" GridLines="None" 
        AllowAutomaticDeletes="True" OnItemDeleted="vd_dele" 
        AllowAutomaticInserts="True" OnItemInserted="vd_insert"
        AllowAutomaticUpdates="True" OnItemUpdated="vd_update" 
        AllowPaging="True" AllowFilteringByColumn="True" AllowSorting="True"
        Skin="Office2007" Width="645px" oninsertcommand="RadGrid1_InsertCommand">
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>

<MasterTableView AutoGenerateColumns="False" DataKeyNames="mataikhoan" 
                DataSourceID="SqlDataSource1" CommandItemDisplay="Top">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>

<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>

    <Columns>
        <telerik:GridBoundColumn DataField="mataikhoan" DataType="System.Int32" 
            FilterControlAltText="Filter mataikhoan column" HeaderText="mataikhoan" 
            ReadOnly="True" SortExpression="mataikhoan" UniqueName="mataikhoan" Visible="false">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="tentaikhoan" 
            FilterControlAltText="Filter tentaikhoan column" HeaderText="tentaikhoan" 
            SortExpression="tentaikhoan" UniqueName="tentaikhoan">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="password" 
            FilterControlAltText="Filter password column" HeaderText="password" 
            SortExpression="password" UniqueName="password">
        </telerik:GridBoundColumn>
        
        <telerik:GridDropDownColumn FilterControlAltText="Filter mavaitro column" DataField="mavaitro" ListTextField="tenvaitro" ListValueField="mavaitro"
                       DataSourceID="SqlDataSource3"  ColumnEditorID="GridDropDownColumnEditor2" SortExpression="mathanhvien"
                        HeaderText="Tên vai trò" UniqueName="mavaitro">
                    </telerik:GridDropDownColumn>
        <telerik:GridBoundColumn DataField="mathanhvien" DataType="System.Int32" Visible="false" 
            FilterControlAltText="Filter mathanhvien column" HeaderText="mathanhvien" 
            SortExpression="mathanhvien" UniqueName="mathanhvien">
        </telerik:GridBoundColumn>
        <telerik:GridDropDownColumn FilterControlAltText="Filter matinhtrangtk column" DataField="matinhtrangtk" ListTextField="tentinhtrangtk" ListValueField="matinhtrangtk"
                       DataSourceID="SqlDataSource2" ColumnEditorID="GridDropDownColumnEditor3" SortExpression="matinhtrangtk"
                        HeaderText="Tên tình trạng" UniqueName="matinhtrangtk">
                    </telerik:GridDropDownColumn>
        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>
                    <telerik:GridButtonColumn ConfirmText="Xóa chuyên mục này?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn" >
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
    </Columns>

<EditFormSettings EditFormType="Template" ColumnNumber="2" CaptionDataField="mataikhoan" CaptionFormatString="Edit properties of Product {0}" InsertCaption="New Taikhoan">
<EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
 <FormTemplate>
                    <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
                        style="border-collapse: collapse; background: white;">
                        <tr>
                            <td colspan="2" style = "font-size: small;text-align:center">
                                <b>Thêm tài khoản</b>
                            </td>
                        </tr>  
        <tr>
            <td style="width: 152px">
                Tên tài khoản</td>
            <td style="width: 203px">
                <asp:TextBox ID="txttentaikhoan" runat="server" Text='<%# Bind("tentaikhoan") %>'></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Nhap tên" ControlToValidate="txttentaikhoan"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td style="width: 152px">
                Password</td>
            <td style="width: 203px">
                <asp:TextBox ID="txtpassword" runat="server" Text='<%# Bind("password") %>'></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="nhập pass" ControlToValidate="txtpassword"></asp:RequiredFieldValidator>
            </td>
        </tr>

        <tr >
            <td style="width: 152px">

               </td>
            <td style="width: 203px">
                <asp:TextBox ID="txtThanhvien" runat="server" Text='<%# Bind("mathanhvien") %>' Visible="false" ></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width: 152px">
                Vai trò</td>
            <td style="width: 203px">
                <asp:DropDownList ID="dropmavaitro" runat="server" Width="100px" SelectedValue='<%# Bind("mavaitro") %>'
                                                DataTextField="tenvaitro" TabIndex="7" DataValueField="mavaitro" DataSourceID="SqlDataSource3"
                                                AppendDataBoundItems="True">
                 <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                </asp:DropDownList>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="chọn vai trò" ControlToValidate="dropmavaitro"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td style="width: 152px">
                Tình trạng<br />
            </td>
            <td style="width: 203px">
                <asp:DropDownList ID="dropmatinhtrang" runat="server" Width="100px" SelectedValue='<%# Bind("matinhtrangtk") %>'
                                                DataTextField="tentinhtrangtk" TabIndex="7" DataValueField="matinhtrangtk" DataSourceID="SqlDataSource2"
                                                AppendDataBoundItems="True">
                <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                </asp:DropDownList>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="chọn tình trạng" ControlToValidate="dropmatinhtrang"></asp:RequiredFieldValidator>
                <br />
            </td>
        </tr>
        <tr>
         <td align="right" colspan="2">
                                 <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                </asp:Button>&nbsp;
                                        <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                        CommandName="Cancel"></asp:Button>
                                  
                                 
                            </td>
        </tr>
                    </table>
                    </FormTemplate>
</EditFormSettings>
</MasterTableView>

            <ClientSettings>
                <Selecting AllowRowSelect="True" />
            </ClientSettings>

<FilterMenu EnableImageSprites="False"></FilterMenu>
    </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:forumConnectionString %>" 
        DeleteCommand="DELETE FROM [TAIKHOAN] WHERE [mataikhoan] = @original_mataikhoan" 
        InsertCommand="INSERT INTO [TAIKHOAN] ([tentaikhoan], [password], [mathanhvien], [mavaitro], [matinhtrangtk]) VALUES (@tentaikhoan, @password, @mathanhvien, @mavaitro, @matinhtrangtk)" 
        OldValuesParameterFormatString="original_{0}" 
        SelectCommand="SELECT * FROM [TAIKHOAN] WHERE ([mathanhvien] = @mathanhvien)" 
        
            
            
        UpdateCommand="UPDATE [TAIKHOAN] SET [tentaikhoan] = @tentaikhoan, [password] = @password, [mavaitro] = @mavaitro, [matinhtrangtk] = @matinhtrangtk WHERE [mataikhoan] = @original_mataikhoan">
        <SelectParameters>
            <asp:SessionParameter Name="mathanhvien" SessionField="mathanhvien" 
                Type="Int32" />
        </SelectParameters>
        <DeleteParameters>

            <asp:Parameter Name="original_mataikhoan" Type="Int32" />
            <asp:Parameter Name="original_tentaikhoan" Type="String" />
            <asp:Parameter Name="original_password" Type="String" />
            <asp:Parameter Name="original_mathanhvien" Type="Int32" />
            <asp:Parameter Name="original_mavaitro" Type="Int32" />
            <asp:Parameter Name="original_matinhtrangtk" Type="Int32" />

        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="tentaikhoan" Type="String" />
            <asp:Parameter Name="password" Type="String" />
            <asp:Parameter Name="mathanhvien" Type="Int32" />
            <asp:Parameter Name="mavaitro" Type="Int32" />
            <asp:Parameter Name="matinhtrangtk" Type="Int32" />

            <asp:Parameter Name="original_mataikhoan" Type="Int32" />
            <asp:Parameter Name="original_tentaikhoan" Type="String" />
            <asp:Parameter Name="original_password" Type="String" />
            <asp:Parameter Name="original_mathanhvien" Type="Int32" />
            <asp:Parameter Name="original_mavaitro" Type="Int32" />
            <asp:Parameter Name="original_matinhtrangtk" Type="Int32" />

        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="tentaikhoan" Type="String" />
            <asp:Parameter Name="password" Type="String" />
            <asp:Parameter Name="mathanhvien" Type="Int32" />
            <asp:Parameter Name="mavaitro" Type="Int32" />
            <asp:Parameter Name="matinhtrangtk" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:forum %>" 
            SelectCommand="SELECT * FROM [TINHTRANGTK]"></asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
            ConnectionString="<%$ ConnectionStrings:forum %>" 
            
            SelectCommand="select * from vaitro where mavaitro not in (select mavaitro from vaitro where mavaitro = 1)"></asp:SqlDataSource>
</asp:Content>
